# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: jaewon

from coin.proto.coin_executor_pb2 import PassiveExecutorConfig
from coin.proto.coin_request_pb2 import StrategyRequestProto
from coin.strategy.mm.subscription import SubscriptionRequest
from coin.experimental.jaewon.strat.pass_model import PassModelConfig
from coin.experimental.jaewon.strat.pass_model_strategy import PassModelStrategyConfig
from coin.exchange.okex_futures.kr_rest.futures_product import OkexFuturesProduct


def second(x):
  return int(x * 10**9)


def strategy_config():
  symbol_str = 'BTC-USD.PERPETUAL'

  strategy_config = PassModelStrategyConfig(
      trade_product=OkexFuturesProduct.FromStr(symbol_str),
      trade_sub_req=SubscriptionRequest('Futures', 'Okex', 'v3_swap'),
      executor_params=PassiveExecutorConfig(
          symbol=symbol_str,
          lot_size=10.,
          min_pos=-50.,
          max_pos=+50.,
          order_update_period=second(2.),
          min_posting_period=second(0.2),
          max_posting_period=second(2.),
          fill_cooldown_period=second(0.01),
          post_only=False,
      ),
      model_config=PassModelConfig(
          symbol_nick='okex-btcusd-perpetual',
          linear_model_filepath='~/deploy/models/model_okex-btcusd-perpetual.pkl.gz',
          bound_price=False,
          sampler_offsets={
              'sampler/low_vol': 3.,
              'sampler/mid_vol': 3.,
              'sampler/high_vol': 3.,
          },
          lt_model_param={'version': 1},
      ),
      init_og_after_min=20,
      exit_after_min=30,
      og_params={},
      strategy_request=StrategyRequestProto(
          strategy_name='pass_model_okex_futures_btcusd_pswap',
          strategy_group='pass_model',
          trader='jaewon',
      ))
  return strategy_config


if __name__ == '__main__':
  print(strategy_config())
